<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        ul,
        li {
            list-style: none;
        }

        #form {
            width: 600px;
            height: 40px;
            border-radius: 10px;
            border: 2px solid #ccc;
            margin: auto;
            margin-top: 100px;
            position: relative;
        }

        #form.active {
            border: none;
        }

        #form #keyWord {
            position: absolute;
            width: 94%;
            height: 100%;
            top: 0px;
            left: 0px;
            z-index: 1;
            border: none;
            outline: none;
            right: 0px;
            bottom: 0px;
            margin: auto;
            background: rgba(0, 0, 0, 0);
            /* border-bottom: 2px solid rgba(0, 0, 0, 0.5); */
        }

        #form .list {
            position: absolute;
            top: -2px;
            left: -2px;
            width: 100%;
            height: auto;
            border-radius: 10px;
            padding-top: 45px;
            border: 2px solid blue;
            display: none;
        }

        #form .list li {
            height: 30px;
            color: #626675;
        }

        b {
            font-weight: 400;
            color: #222;
        }
    </style>
</head>

<body>
    <form id="form" class="">
        <input type="text" id="keyWord" />
        <div class="list">
            <ul>
                <!-- <li data-key="中通快递" class="bdsug-overflow">中<b>通快递</b></li> -->
            </ul>
        </div>
    </form>
</body>
<script>
    var key = document.querySelector('#keyWord');
    var list = document.querySelector('.list');

    function fun(res) {
        if (!res.g == '') {
            console.log(res);
            res.g.forEach(item => {
                let li = document.createElement('li');
                li.innerHTML = `${item.q}<b></b>`;
                list.appendChild(li);
            });
        }
    }

    key.oninput = function () {
        list.style.display = 'block';

        let url =
            " https://www.baidu.com/sugrec?pre=1&p=3&ie=utf-8&json=1&prod=pc&from=pc_web&sugsid=33802,31660,33848,33855,26350,33607,33810&wd=" +
            key.value + "&req=2&csor=1&pwd=zhong&cb=fun ";

        let scr = document.createElement('script');
        scr.setAttribute('src', url);
        document.body.appendChild(scr);
        scr.remove();

        list.innerHTML = '';
    }
    
</script>

</html>